import 'package:flutter/material.dart';
import './myFonts.dart';

//ListView列表组件
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('ListView列表组件 '),
          backgroundColor: Colors.pink[50],
        ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 150,
      child: ListView(
        scrollDirection: Axis.horizontal, //水平方向
        padding: EdgeInsets.all(10),
        children: [
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.pink[100]),
            child: Column(
              children: [
                Image.network("https://www.itying.com/images/flutter/1.png",height: 100,),
                Text('标题1',textAlign: TextAlign.center,),
              ],
            ),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.blue[100]),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.green[100]),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.red[100]),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(
              color: const Color.fromARGB(255, 214, 48, 214),
            ),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(
              color: const Color.fromARGB(255, 187, 221, 248),
            ),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.green[100]),
          ),
          Container(
            width: 120,
            decoration: BoxDecoration(color: Colors.red[100]),
          ),
        ],
      ),
    );
  }
}
